package com.ruoyi.system.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.TDoctorMapper;
import com.ruoyi.system.domain.TDoctor;
import com.ruoyi.system.service.ITDoctorService;
import com.ruoyi.common.core.text.Convert;

/**
 * 医生Service业务层处理
 * 
 * @author 杨一迪
 * @date 2024-12-26
 */
@Service
public class TDoctorServiceImpl extends ServiceImpl<TDoctorMapper,TDoctor> implements ITDoctorService

{
    @Autowired
    private TDoctorMapper tDoctorMapper;

    /**
     * 查询医生
     * 
     * @param id 医生主键
     * @return 医生
     */
    @Override
    public TDoctor selectTDoctorById(Long id)
    {
        return tDoctorMapper.selectTDoctorById(id);
    }

    /**
     * 查询医生列表
     * 
     * @param tDoctor 医生
     * @return 医生
     */
    @Override
    public List<TDoctor> selectTDoctorList(TDoctor tDoctor)
    {
        return tDoctorMapper.selectTDoctorList(tDoctor);
    }

    /**
     * 新增医生
     * 
     * @param tDoctor 医生
     * @return 结果
     */
    @Override
    public int insertTDoctor(TDoctor tDoctor)
    {
        tDoctor.setCreateTime(DateUtils.getNowDate());
        return tDoctorMapper.insertTDoctor(tDoctor);
    }

    /**
     * 修改医生
     * 
     * @param tDoctor 医生
     * @return 结果
     */
    @Override
    public int updateTDoctor(TDoctor tDoctor)
    {
        tDoctor.setUpdateTime(DateUtils.getNowDate());
        return tDoctorMapper.updateTDoctor(tDoctor);
    }

    /**
     * 批量删除医生
     * 
     * @param ids 需要删除的医生主键
     * @return 结果
     */
    @Override
    public int deleteTDoctorByIds(String ids)
    {
        return tDoctorMapper.deleteTDoctorByIds(Convert.toStrArray(ids));
    }

    /**
     * 批量软删除医生
     *
     * @param ids 需要软删除的医生主键
     * @return 结果
     */
    @Override
    public int softDeleteTDoctorByIds(String ids)
    {
        String[] strArray = Convert.toStrArray(ids);
        int count = 0;
        for (String s : strArray) {
            TDoctor tDoctor = tDoctorMapper.selectTDoctorById(Long.valueOf(s));
            tDoctor.setIsDelete(1);
            int i = tDoctorMapper.updateTDoctor(tDoctor);
            count = count + i;
        }
        return count;
    }

    /**
     * 删除医生信息
     * 
     * @param id 医生主键
     * @return 结果
     */
    @Override
    public int deleteTDoctorById(Long id)
    {
        return tDoctorMapper.deleteTDoctorById(id);
    }
}
